package rtda.stack;

public class Slot {
    /*
        A single local variable can hold a value of type boolean, byte, char, short, int, float, reference, or returnAddress. A pair of local variables can hold a value of type long or double.
     */
    public static final int BOOLEAN = 0;
    public static final int BYTE = 1;
    public static final int CHAR = 2;
    public static final int SHORT = 3;
    public static final int INT = 4;
    public static final int FLOAT = 5;
    public static final int REFERENCE = 6;

    // LONG和DOUBLE需要两个字节 使用的小端存储
    public static final int LONG_LOW = 7;
    public static final int LONG_HIGH = 8;
    public static final int DOUBLE_LOW = 9;
    public static final int DOUBLE_HIGH = 10;

    // 存储的到类型 只有数值和引用两类
    public final Integer num;
    public final Object ref;
    public int type;

    public Slot(Integer num, int type)
    {
        this.num = num;
        this.ref = null;
        this.type = type;
    }

    public Slot(Object ref)
    {
        this.num = null;
        this.ref = ref;
        this.type = REFERENCE;
    }
}
